﻿using web_api_demo101.Entities;
using web_api_demo101.Repositories;
using web_api_demo101.Repositories.Assist;

namespace web_api_demo101.Services.Impl;


public class StudentService : IStudentService
{
    private readonly IStudentRepository _studentRepository;
    public StudentService(IStudentRepository repository)
    {
        this._studentRepository = repository;
    }
    public int Add(Student stu)
    {
        return _studentRepository.Add(stu);
    }

    public PageData<Student> PaginationQuery(int page, int pagesize)
    {
        return _studentRepository.PaginationQuery(page, pagesize);
    }

    public int Update(Student stu)
    {
        var target = _studentRepository.GetById(stu.Id);
        target.SchoolId = stu.SchoolId;
        target.Name = stu.Name;
        return _studentRepository.Update(target);
    }
}

